using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.OleDb;
namespace DAO
{
    public class BaoCaoSuDungThuocDAO
    {
        DataProvider Provider;
        public BaoCaoSuDungThuocDAO()
        {
            Provider = new DataProvider();
        }

        public DataTable LayThongTinBaoCaoSuDungThuoc(int thangBaoCao)
        {
            Provider.Connect();
            string str = "select ctpk.MaLoaiThuoc as MaLoaiThuoc2,t.TenLoaiThuoc as TenLoaiThuoc2,dv.TenDV as TenDV2,sum(ctpk.SoLuong) as SoLuong2,Count(ctpk.MaLoaiThuoc) as SoLanDung From ChiTietPK ctpk,Thuoc t,DONVI dv,PhieuKham pk Where ctpk.MaLoaiThuoc = t.MaLoaiThuoc and dv.MaDV = ctpk.MaDV and pk.MaPhieuKham = ctpk.MaPK and Month(pk.NgayKham) = " + thangBaoCao + " Group By ctpk.MaLoaiThuoc, t.TenLoaiThuoc, dv.TenDV";
            DataTable dt = new DataTable();
            OleDbDataAdapter da;
            da = new OleDbDataAdapter(str, Provider.cn);
            da.Fill(dt);
            Provider.Disconnect();
            return dt;
        }
    }
}
